//
//  DSYNAVViewController.m
//  BLDMusics
//
//  Created by dllo on 16/3/24.
//  Copyright © 2016年 李晓丹. All rights reserved.
//

#import "DSYNAVViewController.h"


@interface DSYNAVViewController ()

@end

@implementation DSYNAVViewController

+ (instancetype)shareNavWithRootViewController:(UIViewController *)rootViewController
{
    static DSYNAVViewController *nav = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        nav = [[DSYNAVViewController alloc] initWithRootViewController:rootViewController];
        
        nav.navigationBar.translucent = YES;
        [nav.navigationBar setBackgroundImage:[DSYNAVViewController imageWithColor:[[UIColor cyanColor] colorWithAlphaComponent:0.3]] forBarMetrics:UIBarMetricsDefault];
    });
    return nav;
}

+ (UIImage *)imageWithColor:(UIColor *)color {
    
    // 描述矩形
    CGRect rect = CGRectMake(0, 0, 1, 1);
    // 开启位图上下文
    UIGraphicsBeginImageContext(rect.size);
    // 获取位图上下文
    CGContextRef context = UIGraphicsGetCurrentContext();
    // 使用color演示填充上下文
    CGContextSetFillColorWithColor(context, [color CGColor]);
    // 渲染上下文
    CGContextFillRect(context, rect);
    // 从上下文中获取图片
    UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();
    // 结束上下文
    UIGraphicsEndImageContext();
    
    return theImage;
}


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
